package com.wufun.overseas.adapters;

import android.content.Context;
import android.content.res.Resources;
import android.graphics.Color;
import android.graphics.LightingColorFilter;
import android.graphics.drawable.Animatable;
import android.graphics.drawable.Drawable;
import android.text.SpannableStringBuilder;
import android.text.TextUtils;
import android.text.method.LinkMovementMethod;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;


import com.facebook.drawee.backends.pipeline.Fresco;
import com.facebook.drawee.controller.ControllerListener;
import com.facebook.drawee.interfaces.DraweeController;
import com.facebook.drawee.view.SimpleDraweeView;
import com.facebook.imagepipeline.image.ImageInfo;
import com.wufun.baselibrary.download.CommonDownloadTask;
import com.wufun.baselibrary.download.UtilsMy;
import com.wufun.baselibrary.impl.AdapterInterface;
import com.wufun.overseas.R;
import com.wufun.overseas.main.activity.PostDetailsActivtiy;
import com.wufun.overseas.main.activity.SetWebViewActivity;
import com.wufun.overseas.models.bean.ForumBean;
import com.wufun.overseas.models.bean.RecommendLabelTag;
import com.wufun.overseas.models.db.DownLoadModel;
import com.wufun.overseas.tools.DownloadManager;
import com.wufun.overseas.utils.DateUtils;
import com.wufun.overseas.utils.ForumUtil;
import com.wufun.overseas.utils.StringUtils;
import com.wufun.overseas.view.HListView;
import com.wufun.overseas.view.StandardVideoView;

import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List;
import java.util.logging.Logger;


import fm.jiecao.jcvideoplayer_lib.JCVideoPlayer;

import static com.wufun.overseas.adapters.ForumPostsAdapter.ViewType.BAIDUADBANNER;
import static com.wufun.overseas.adapters.ForumPostsAdapter.ViewType.COMMENT_HEADER;
import static com.wufun.overseas.adapters.ForumPostsAdapter.ViewType.COMMENT_IMAGE;
import static com.wufun.overseas.adapters.ForumPostsAdapter.ViewType.COMMENT_MESSAGE;
import static com.wufun.overseas.adapters.ForumPostsAdapter.ViewType.COMMENT_MESSAGE_REPLY;
import static com.wufun.overseas.adapters.ForumPostsAdapter.ViewType.EMPLOYEE_TAGS;
import static com.wufun.overseas.adapters.ForumPostsAdapter.ViewType.POST_FOOTER;
import static com.wufun.overseas.adapters.ForumPostsAdapter.ViewType.POST_FOOTER1;
import static com.wufun.overseas.adapters.ForumPostsAdapter.ViewType.POST_GAME;
import static com.wufun.overseas.adapters.ForumPostsAdapter.ViewType.POST_HEADER;
import static com.wufun.overseas.adapters.ForumPostsAdapter.ViewType.POST_HEADER1;
import static com.wufun.overseas.adapters.ForumPostsAdapter.ViewType.POST_IMAGE;
import static com.wufun.overseas.adapters.ForumPostsAdapter.ViewType.POST_IMAGE_THUMBNAIL;
import static com.wufun.overseas.adapters.ForumPostsAdapter.ViewType.POST_MESSAGE;
import static com.wufun.overseas.adapters.ForumPostsAdapter.ViewType.POST_SUBJECT;
import static com.wufun.overseas.adapters.ForumPostsAdapter.ViewType.POST_VIDEO;
import static com.wufun.overseas.adapters.ForumPostsAdapter.ViewType.values;
import static com.wufun.overseas.view.XListView2.TAG;


/**
 * Created by yangg on 2017/12/5.
 */

public class ForumPostsAdapter extends BaseAdapter {

    Context mContext;
    private List<ViewBean> itemBeans;
    private AdapterInterface mAdapterInterface;
    private boolean isReflash = false;
    int pro;   //gameView 里面的进度条
    String speed;   //gameView 下载速度

    public void setReflash() {
        isReflash = !isReflash;
        notifyDataSetChanged();
    }

    public ForumPostsAdapter(Context mContext, AdapterInterface mAdapterInterface) {
        this.mContext = mContext;
        itemBeans = new ArrayList<>();
        this.mAdapterInterface = mAdapterInterface;
        initAttrs();
    }

    @Override
    public int getCount() {
        if (itemBeans != null) {
            return itemBeans.size();
        }
        return 0;
    }

    public void getSpeed(int progress, String speeds) {
        pro = progress;
        speed = speeds;
    }

    @Override
    public Object getItem(int position) {
        if (itemBeans != null) {
            return itemBeans.get(position).getObj();
        }
        return null;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public int getViewTypeCount() {
        return values().length;
    }

    @Override
    public int getItemViewType(int position) {
        if (this.itemBeans != null) {
            ViewBean bean = this.itemBeans.get(position);
            return bean.getViewType().ordinal();
        }
        return -1;
    }

    public List<ViewBean> getItemBeans() {
        return itemBeans;
    }

    @Override
    public void notifyDataSetChanged() {
        super.notifyDataSetChanged();
    }

    public void setItemBeans(List<ViewBean> itemBeans) {
        if (itemBeans == null) return;
        if (this.itemBeans == null) itemBeans = new ArrayList<ViewBean>();

        this.itemBeans.clear();
        this.itemBeans.addAll(itemBeans);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        int type = getItemViewType(position);
        if (type == POST_HEADER.ordinal()) {
            convertView = getPostHeaderView(position, convertView, parent);
        } else if (type == POST_HEADER1.ordinal()) {
            convertView = getPostHeader1View(position, convertView, parent);
        } else if (type == POST_FOOTER.ordinal()) {
            convertView = getPostFooterView(position, convertView, parent);
        } else if (type == POST_FOOTER1.ordinal()) {
            convertView = getPostFooter1View(position, convertView, parent);
        } else if (type == POST_GAME.ordinal()) {
            convertView = getPostGameView(position, convertView, parent);
        } else if (type == POST_IMAGE.ordinal()) {
            convertView = getPostImageView(position, convertView, parent);
        } else if (type == POST_VIDEO.ordinal()) {
            convertView = getPostVideoView(position, convertView, parent);
        } else if (type == POST_IMAGE_THUMBNAIL.ordinal()) {
            convertView = getPostImageThumbnailView(position, convertView, parent);
        } else if (type == POST_MESSAGE.ordinal()) {
            convertView = getPostMessageView(position, convertView, parent);
        } else if (type == POST_SUBJECT.ordinal()) {
            convertView = getPostSubjectView(position, convertView, parent);
        } else if (type == COMMENT_HEADER.ordinal()) {
            convertView = getCommentHeaderView(position, convertView, parent);
        } else if (type == COMMENT_MESSAGE.ordinal()) {
            convertView = getCommentMessageView(position, convertView, parent);
        } else if (type == COMMENT_IMAGE.ordinal()) {
            convertView = getCommentImageView(position, convertView, parent);
        } else if (type == COMMENT_MESSAGE_REPLY.ordinal()) {
            convertView = getCommentMessageReplyView(position, convertView, parent);
        } else if (type == BAIDUADBANNER.ordinal()) {
            convertView = getBaiduBannerView(position, convertView, parent);
        } else if (type == EMPLOYEE_TAGS.ordinal()) {
            convertView = getEmployeeTagsView(position, convertView, parent);
        }

        return convertView;
    }

    class CommentImageViewHolder extends ViewHolder {
        public SimpleDraweeView imgV;
    }

    class CommentMessageViewHolder extends ViewHolder {

        public TextView commentMessageV;
    }

    class PostSubjectViewHolder extends ViewHolder {

        public Button bestV;
        public TextView subjectV;
    }

    class PostMessageViewHolder extends ViewHolder {

        public TextView messageV;
    }

    class PostImageThumbnailViewHolder extends ViewHolder {

        public TextView imgCountV;
        public RelativeLayout imgContainerV;
    }

    class PostVideoViewHolder extends ViewHolder {
        public ImageView playV;
        public SimpleDraweeView coverV;
        public ImageView iv_play;
        public StandardVideoView videoPlayer;
    }

    class PostImageViewHolder extends ViewHolder {

        public SimpleDraweeView imgV;
        public TextView imgTagGifV;
    }

    class PostGameViewHolder extends ViewHolder {
        public SimpleDraweeView icon;
        public TextView name;
        public LinearLayout mgListviewItemInstall;
        public TextView size;
        public TextView describe;
        public LinearLayout linearLayout2;
        public LinearLayout ll_game;
        public LinearLayout tipsLayout;
        public TextView appSize;
        public TextView gamesize;
        public TextView lodingInfo;
        public ProgressBar progressBar;
        public ProgressBar progressBarZip;
        public ProgressBar pbar;
        public LinearLayout ll_pro;
        public TextView tv_count,tv_state;
        public View line;
        public View relateLayoutApp;
        public TextView tv_down_name;
    }

    class PostFooterViewHolder extends ViewHolder {

        public TextView fnameV;
        public TextView postViewV;
        public TextView postCommentV;
        public TextView postPraiseV;
    }

    class PostHeader1ViewHolder extends ViewHolder {

        public SimpleDraweeView avatarV;
        public TextView nicknameV;
        public TextView addTimeV;
        public TextView stickieV;
        public View dividerV;
        public Button postHostV;
        public ImageView moderatorV;
        public RelativeLayout forumExtFuncV;
        public ImageView flagBestAnswerV;
        public ImageView officialIcon;
        public TextView copperTitleV;
        public TextView groupName;
        public TextView moderator;
        public TextView member_honor;
        public View groupParent;
    }

    class PostHeaderViewHolder extends ViewHolder {

        public SimpleDraweeView avatarV;
        public TextView nicknameV;
        public TextView addTimeV;
        public TextView stickieV;
        public View dividerV;
        public Button postHostV;
        public ImageView moderatorV;
        public RelativeLayout forumExtFuncV;
        public ImageView flagBestAnswerV;
        public ImageView officialIcon;
        public TextView copperTitleV;
    }

    private View getPostHeaderView(int position, View convertView, ViewGroup parent) {
        PostHeaderViewHolder holder;
        if (convertView != null) {
            holder = (PostHeaderViewHolder) convertView.getTag();
        } else {
            holder = new PostHeaderViewHolder();
            convertView = LayoutInflater.from(mContext).inflate(R.layout.mg_forum_post_activity_item_post_header, null);

            holder.dividerV = convertView.findViewById(R.id.forum_post_divider);
            holder.avatarV = (SimpleDraweeView) convertView.findViewById(R.id.forum_post_avatar_src);
            holder.nicknameV = (TextView) convertView.findViewById(R.id.forum_post_nickname);
            holder.addTimeV = (TextView) convertView.findViewById(R.id.forum_post_add_time);
            holder.stickieV = (TextView) convertView.findViewById(R.id.forum_post_stickie);
            holder.moderatorV = (ImageView) convertView.findViewById(R.id.forum_post_moderator);
            holder.officialIcon = (ImageView) convertView.findViewById(R.id.officialIcon);
            holder.forumExtFuncV = (RelativeLayout) convertView.findViewById(R.id.forumExtFunc);
            holder.postHostV = (Button) convertView.findViewById(R.id.forum_post_host);
            holder.flagBestAnswerV = (ImageView) convertView.findViewById(R.id.flagBestAnswer);
            holder.copperTitleV = (TextView) convertView.findViewById(R.id.copperTitleTv);

            convertView.setTag(holder);
        }

        try {
            ViewBean.PostHeader item = (ViewBean.PostHeader) getItem(position);
            if (item == null) return convertView;

            try {
//                UtilsMy.setVipTextColor(mContext, holder.nicknameV, item.vip_level, item.svip_level);
//                holder.vipFlagV.setVipData(item.vip_level, item.svip_level);
            } catch (Exception e) {
                e.printStackTrace();
            }

            switch (item.solveFlag) {
                case 1:
                    holder.flagBestAnswerV.setVisibility(View.VISIBLE);
                    break;
                default:
                    holder.flagBestAnswerV.setVisibility(View.GONE);
                    break;
            }

            holder.forumExtFuncV.setVisibility(View.VISIBLE);
            if (item.removeDivider) {
                holder.dividerV.setVisibility(View.GONE);
            } else {
                holder.dividerV.setVisibility(View.VISIBLE);
            }
            holder.postHostV.setVisibility(View.VISIBLE);
            holder.nicknameV.setText(item.nickName);
            holder.addTimeV.setText(DateUtils.FormatForDownloadTime(item.timestamps * 1000));
            if (item.isTop) {
                holder.stickieV.setVisibility(View.VISIBLE);
            } else {
                holder.stickieV.setVisibility(View.GONE);
            }

            if (item.officialAccount) {
                holder.officialIcon.setVisibility(View.VISIBLE);
            } else {
                holder.officialIcon.setVisibility(View.GONE);
            }
            if (item.isModerator) {
                holder.nicknameV.setTextColor(mContext.getResources().getColor(R.color.app_blue_color));
                holder.moderatorV.setVisibility(View.VISIBLE);
            } else {
//                UtilsMy.setVipTextColor(mContext, holder.nicknameV, item.vip_level, item.svip_level, R.color.forum_nickname_color);
                holder.moderatorV.setVisibility(View.GONE);
            }
//            MyImageLoader.loadUserIcon(holder.avatarV, item.avatarSrc);
            holder.avatarV.setImageURI(item.avatarSrc);
            setOnCommentReplyCancel(convertView);

            holder.forumExtFuncV.setVisibility(View.GONE);
            setOnDelete(holder.forumExtFuncV, item.pid);

            ForumUtil.goSpec(holder.avatarV, holder.nicknameV, holder.addTimeV);
//            ForumUtil.goSpec1(holder.vipFlagV);

            String battleTitle = item.battleTitle;
            String color = item.battleColor;
            if (null != holder.copperTitleV) {
                if (!TextUtils.isEmpty(battleTitle)) {
                    holder.copperTitleV.setVisibility(View.VISIBLE);
                    holder.copperTitleV.setText(battleTitle);
                    Drawable d = mContext.getResources().getDrawable(R.drawable.forum_post_host);
                    if (!TextUtils.isEmpty(color)
                            && color.length() == 7
                            && color.contains("#")) {
                    } else {
                        color = "#2fccdf";
                    }
                    d.setColorFilter(new LightingColorFilter(Color.parseColor(color), Color.parseColor(color)));
                    holder.copperTitleV.setBackgroundDrawable(d);
                } else {
                    holder.copperTitleV.setVisibility(View.GONE);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

        return convertView;
    }

    class EmployeeTagsViewHolder extends ViewHolder {
        public HListView list;
    }

    HTagsAdapter hTagsAdapter;

    private View getEmployeeTagsView(int position, View convertView, ViewGroup parent) {
        EmployeeTagsViewHolder holder;
        if (convertView != null) {
            holder = (EmployeeTagsViewHolder) convertView.getTag();
        } else {
            holder = new EmployeeTagsViewHolder();
            convertView = LayoutInflater.from(mContext).inflate(R.layout.mg_forum_post_activity_item_employee_tags, null);
            holder.list = (HListView) convertView.findViewById(R.id.list);

            convertView.setTag(holder);
        }

        try {
            ViewBean.EmployeeTags item = (ViewBean.EmployeeTags) getItem(position);
            if (item == null) return convertView;

            if (hTagsAdapter == null)
                hTagsAdapter = new HTagsAdapter(mContext);
            hTagsAdapter.setFid(item.fid);
            hTagsAdapter.setFname(item.fname);
            hTagsAdapter.getTags().clear();
            hTagsAdapter.getTags().addAll(item.employ_tags);
            holder.list.setAdapter(hTagsAdapter);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return convertView;
    }

    public static class HTagsAdapter extends BaseAdapter {

        private final Context context;
        private List<RecommendLabelTag> tags;
        private int fid;
        private String fname;

        public HTagsAdapter(Context mContext, List<RecommendLabelTag> employ_tags) {
            this.context = mContext;
            this.tags = employ_tags;
        }

        public HTagsAdapter(Context mContext) {
            this.context = mContext;
            tags = new ArrayList<>();
        }

        public List<RecommendLabelTag> getTags() {
            return tags;
        }

        public void setTags(List<RecommendLabelTag> tags) {
            this.tags = tags;
        }

        @Override
        public int getCount() {
            return tags != null ? tags.size() : 0;
        }

        @Override
        public Object getItem(int i) {
            if (tags != null && i < tags.size()) {
                return tags.get(i);
            }
            return null;
        }

        @Override
        public long getItemId(int i) {
            return i;
        }

        @Override
        public View getView(int i, View view, ViewGroup viewGroup) {
            TagViewHolder holder;
            if (view == null) {
                holder = new TagViewHolder();
                view = LayoutInflater.from(context).inflate(R.layout.forum_group_tag_item, null);
                holder.tagTv = (TextView) view.findViewById(R.id.tagTv);
                view.setTag(holder);
            } else {
                holder = (TagViewHolder) view.getTag();
            }
            if (holder.tagTv == null) return view;

            final RecommendLabelTag tag = (RecommendLabelTag) getItem(i);
            if (tag != null) {
                holder.tagTv.setText("#" + tag.getTag_name() + "#");
                holder.tagTv.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
//                        IntentUtil.getInstance().goMainLabelActivity(view.getContext(), tag.getTag_id(), fid, fname);
                    }
                });
            }
            return view;
        }

        public void setFid(int fid) {
            this.fid = fid;
        }

        public void setFname(String fname) {
            this.fname = fname;
        }

        class TagViewHolder {
            TextView tagTv;
        }
    }

    private View getBaiduBannerView(int position, View convertView, ViewGroup parent) {

//        if (convertView == null) {
//            convertView = (View) getItem(position);
//        } else {
//            if (convertView instanceof BaiduAdBannerRelativeLayout) {
//                BaiduAdBannerRelativeLayout layout = (BaiduAdBannerRelativeLayout) getItem(position);
//                ((ViewGroup) convertView).removeAllViews();
//                ((ViewGroup) convertView).removeView(layout.getAdView());
//                ((ViewGroup) convertView).addView(layout.getAdView());
//            }
//        }
//
//        return convertView;
        return (View) getItem(position);
    }

    private View getPostHeader1View(int position, View convertView, ViewGroup parent) {
        PostHeader1ViewHolder holder;
        if (convertView != null) {
            holder = (PostHeader1ViewHolder) convertView.getTag();
        } else {
            holder = new PostHeader1ViewHolder();
            convertView = LayoutInflater.from(mContext).inflate(R.layout.mg_forum_post_activity_item_post_header1, null);

            holder.dividerV = convertView.findViewById(R.id.forum_post_divider);
            holder.avatarV = (SimpleDraweeView) convertView.findViewById(R.id.forum_post_avatar_src);
            holder.nicknameV = (TextView) convertView.findViewById(R.id.forum_post_nickname);
            holder.addTimeV = (TextView) convertView.findViewById(R.id.forum_post_add_time);
            holder.stickieV = (TextView) convertView.findViewById(R.id.forum_post_stickie);
            holder.moderatorV = (ImageView) convertView.findViewById(R.id.forum_post_moderator);
            holder.officialIcon = (ImageView) convertView.findViewById(R.id.officialIcon);
            holder.forumExtFuncV = (RelativeLayout) convertView.findViewById(R.id.forumExtFunc);
            holder.postHostV = (Button) convertView.findViewById(R.id.forum_post_host);
            holder.flagBestAnswerV = (ImageView) convertView.findViewById(R.id.flagBestAnswer);
            holder.copperTitleV = (TextView) convertView.findViewById(R.id.copperTitleTv);

            holder.groupName = (TextView) convertView.findViewById(R.id.groupName);
            holder.moderator = (TextView) convertView.findViewById(R.id.moderator);
            holder.member_honor = (TextView) convertView.findViewById(R.id.member_honor);
            holder.groupParent = convertView.findViewById(R.id.groupParent);

            convertView.setTag(holder);
        }

        try {
            ViewBean.PostHeader1 item = (ViewBean.PostHeader1) getItem(position);
            if (item == null) return convertView;

            try {
//                UtilsMy.setVipTextColor(mContext, holder.nicknameV, item.vip_level, item.svip_level);
            } catch (Exception e) {
                e.printStackTrace();
            }

            switch (item.solveFlag) {
                case 1:
                    holder.flagBestAnswerV.setVisibility(View.VISIBLE);
                    break;
                default:
                    holder.flagBestAnswerV.setVisibility(View.GONE);
                    break;
            }

//            holder.forumExtFuncV.setVisibility(View.VISIBLE);
            if (item.removeDivider) {
                holder.dividerV.setVisibility(View.GONE);
            } else {
                holder.dividerV.setVisibility(View.VISIBLE);
            }
            holder.postHostV.setVisibility(View.VISIBLE);
            holder.nicknameV.setText(item.nickName);
            holder.addTimeV.setText(DateUtils.FormatForDownloadTime(item.timestamps * 1000));
            if (item.isTop) {
                holder.stickieV.setVisibility(View.VISIBLE);
            } else {
                holder.stickieV.setVisibility(View.GONE);
            }

            if (item.officialAccount) {
                holder.officialIcon.setVisibility(View.VISIBLE);
            } else {
                holder.officialIcon.setVisibility(View.GONE);
            }
            if (item.isModerator) {
                holder.nicknameV.setTextColor(mContext.getResources().getColor(R.color.app_blue_color));
                holder.moderatorV.setVisibility(View.VISIBLE);
            } else {
//                UtilsMy.setVipTextColor(mContext, holder.nicknameV, item.vip_level, item.svip_level, R.color.forum_nickname_color);
                holder.moderatorV.setVisibility(View.GONE);
            }
//            MyImageLoader.loadUserIcon(holder.avatarV, item.avatarSrc);
            holder.avatarV.setImageURI(item.avatarSrc);
            if (item.moderator) {
                holder.moderator.setVisibility(View.VISIBLE);
            } else {
                holder.moderator.setVisibility(View.GONE);
            }
            if (!TextUtils.isEmpty(item.member_honor)) {
                holder.member_honor.setVisibility(View.VISIBLE);
                holder.member_honor.setText(item.member_honor);
            } else {
                holder.member_honor.setVisibility(View.GONE);
            }
            holder.groupName.setText(item.fname);
//            setOnGoForumGroup(holder.groupParent, item.fid);

            setOnCommentReplyCancel(convertView);

            holder.forumExtFuncV.setVisibility(View.GONE);
            setOnDelete(holder.forumExtFuncV, item.pid);

            ForumUtil.goSpec(holder.avatarV, holder.nicknameV, holder.addTimeV);
//            ForumUtil.goSpec1(holder.vipFlagV);

            String battleTitle = item.battleTitle;
            String color = item.battleColor;
            if (null != holder.copperTitleV) {
                if (!TextUtils.isEmpty(battleTitle)) {
                    holder.copperTitleV.setVisibility(View.VISIBLE);
                    holder.copperTitleV.setText(battleTitle);
                    Drawable d = mContext.getResources().getDrawable(R.drawable.forum_post_host);
                    if (!TextUtils.isEmpty(color)
                            && color.length() == 7
                            && color.contains("#")) {
                    } else {
                        color = "#2fccdf";
                    }
                    d.setColorFilter(new LightingColorFilter(Color.parseColor(color), Color.parseColor(color)));
                    holder.copperTitleV.setBackgroundDrawable(d);
                } else {
                    holder.copperTitleV.setVisibility(View.GONE);
                }
            }

//            setPostGag(holder.avatarV, item.uid);
        } catch (Exception e) {
            e.printStackTrace();
        }

        return convertView;
    }

    public void setOnDelete(View v, final int fid) {
        v.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (mForumPostsOnClickListener != null) {
                    mForumPostsOnClickListener.onDelete(fid);
                }
            }
        });
    }

//    private void setPostGag(View v, final int gagUid) {
//        if (v == null) return;
//        v.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View view) {
//                String uid = AccountUtil_.getInstance_(view.getContext()).getUid();
//                if (!TextUtils.isEmpty(uid)
//                        && !uid.equals(gagUid + ""))
//                    if (mForumPostsOnClickListener != null) {
//                        mForumPostsOnClickListener.onPostGag(gagUid);
//                    }
//            }
//        });
//    }

    private View getPostFooterView(int position, View convertView, ViewGroup parent) {
        PostFooterViewHolder holder;
        if (convertView != null) {
            holder = (PostFooterViewHolder) convertView.getTag();
        } else {
            holder = new PostFooterViewHolder();
            convertView = LayoutInflater.from(mContext).inflate(R.layout.mg_forum_post_activity_item_post_footer, null);
            holder.fnameV = (TextView) convertView.findViewById(R.id.forum_name);
            holder.postViewV = (TextView) convertView.findViewById(R.id.forum_post_view);
            holder.postCommentV = (TextView) convertView.findViewById(R.id.forum_post_commit);
            holder.postPraiseV = (TextView) convertView.findViewById(R.id.forum_post_praise);

            convertView.setTag(holder);
        }

        try {
            ViewBean.PostFooter item = (ViewBean.PostFooter) getItem(position);
            if (item == null) return convertView;

            if (item.isShowFooterDivider) {
                convertView.findViewById(R.id.post_footer_divider).setVisibility(View.VISIBLE);
            } else {
                convertView.findViewById(R.id.post_footer_divider).setVisibility(View.GONE);
            }

            holder.fnameV.setText(item.fname);
            if (StringUtils.isEmpty(item.fname)) {
                ((ViewGroup) holder.fnameV.getParent()).setVisibility(View.GONE);
            } else {
                ((ViewGroup) holder.fnameV.getParent()).setVisibility(View.VISIBLE);
            }

            ForumUtil.setTextViewValue(holder.postViewV, item.viewTotal + "", "0");
            ForumUtil.setTextViewValue(holder.postCommentV, item.commentTotal + "", "0");
            modifyPraiseView(convertView, item.isPraise, item.praiseTotal);

            final int pid = item.postId;
            ((View) holder.postPraiseV.getParent()).setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {

                    Animation scaleAnim = AnimationUtils.loadAnimation(mContext, R.anim.scale_reset);
                    v.findViewById(R.id.forum_post_praise_icon).startAnimation(scaleAnim);


                    if (mForumPostsOnClickListener != null) {
                        mForumPostsOnClickListener.onPraise(pid);
                    }
                }
            });
        } catch (Exception e) {
            e.printStackTrace();
        }
        return convertView;
    }


    //点赞
    private void modifyPraiseView(View parent, boolean like, int count) {
        TextView praise = (TextView) parent.findViewById(R.id.forum_post_praise);
        ImageView praiseIcon = (ImageView) parent.findViewById(R.id.forum_post_praise_icon);
        if (like) {
            praiseIcon.setImageResource(R.drawable.like);
            praise.setText(count + "");
        } else {
            praiseIcon.setImageResource(R.drawable.unlike);
            praise.setText(count + "");
        }
    }

    private View getPostFooter1View(int position, View convertView, ViewGroup parent) {
        PostFooterViewHolder holder;
        if (convertView != null) {
            holder = (PostFooterViewHolder) convertView.getTag();
        } else {
            holder = new PostFooterViewHolder();
            convertView = LayoutInflater.from(mContext).inflate(R.layout.mg_forum_post_activity_item_post_footer1, null);

            convertView.setTag(holder);
        }
        return convertView;
    }


    private View getPostGameView(final int position, View convertView, ViewGroup parent) {
        final PostGameViewHolder holder;
        int index = 0;
        if (convertView != null) {
            holder = (PostGameViewHolder) convertView.getTag();
        } else {
            holder = new PostGameViewHolder();
            convertView = LayoutInflater.from(mContext).inflate(R.layout.mg_forum_post_activity_item_post_game, null);

            holder.icon = (SimpleDraweeView) convertView.findViewById(R.id.mgListviewItemIcon);
            holder.name = (TextView) convertView.findViewById(R.id.mgListviewItemAppname);
            holder.ll_game = convertView.findViewById(R.id.ll_game);
            holder.mgListviewItemInstall = (LinearLayout) convertView.findViewById(R.id.mgListviewItemInstall);
            holder.size = (TextView) convertView.findViewById(R.id.mgListviewItemSize);
            holder.describe = (TextView) convertView.findViewById(R.id.mgListviewItemDescribe);
            holder.linearLayout2 = (LinearLayout) convertView.findViewById(R.id.linearLayout2);
            holder.tipsLayout = (LinearLayout) convertView.findViewById(R.id.tipsLayout);
            holder.appSize = (TextView) convertView.findViewById(R.id.appSize);
            holder.gamesize = (TextView) convertView.findViewById(R.id.gamesize);
            holder.lodingInfo = (TextView) convertView.findViewById(R.id.loding_info);
            holder.progressBar = (ProgressBar) convertView.findViewById(R.id.progressBar);
            holder.progressBarZip = (ProgressBar) convertView.findViewById(R.id.progressBarZip);
            holder.line = convertView.findViewById(R.id.line);
            holder.relateLayoutApp = convertView.findViewById(R.id.relateLayoutApp);
            holder.tv_down_name = (TextView) convertView.findViewById(R.id.tv_down_name);

            convertView.setTag(holder);
        }


        try {
            ViewBean.PostGame item = (ViewBean.PostGame) getItem(position);
            if (item == null) return convertView;
            final ForumBean.GameInfo gameInfo = item.gameInfo;
            final String postId = item.pid;
            final String gameId = gameInfo.getGame_id();

            //下载按钮样式
            holder.mgListviewItemInstall.setBackgroundResource(R.drawable.detial_fourm_butn_selector1);
            // 这里设置了 btn 现在是Textview 的宽度 我注释掉了
//            int                         width  = mContext.getResources().getDimensionPixelSize(R.dimen.dimen_dp_70);
//            RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) holder.mgListviewItemInstall.getLayoutParams();
//            params.width = width;
//            holder.mgListviewItemInstall.setLayoutParams(params);

            holder.name.setText(gameInfo.getGame_name());// 游戏名称
            holder.describe.setText(gameInfo.getGame_desc());// 描述信息

            //游戏大小
            String gameSize = gameInfo.getGame_size();
            long apps = 0;
            if (StringUtils.isNotEmpty(gameSize)) {
                long appSize = (long) (Double.parseDouble(gameSize) * 1024 * 1024);
                apps=appSize;
                //M - KB -B
                gameSize = UtilsMy.FormatFileSize(appSize);
                holder.gamesize.setText(gameSize);
                holder.gamesize.setVisibility(View.VISIBLE);
                holder.ll_game.setVisibility(View.VISIBLE);

            }

            if (pro == 0) {
                DownLoadModel temp = DownloadManager.getInstance().getDownloadByUrl(item.gameInfo.getGame_down_url_mote());
                if (DownloadManager.getInstance().getAllNotFinishDownload()==true){
                    pro = temp.getProgress();
                }

            }

            //游戏icon
//            MyImageLoader.load(holder.icon, gameInfo.getGame_ico_remote(), MyImageLoader.makeForumGameParams(mContext));
            holder.icon.setImageURI(gameInfo.getGame_ico_remote());

            //游戏tag
            List<ForumBean.GameInfo.GameTagInfo> tipBeans = gameInfo.getGame_tag_info();
            String btn_state = "";
            ;
            holder.mgListviewItemInstall.setBackgroundResource(R.drawable.recom_blue_butn);
            holder.tv_down_name.setTextColor(mContext.getResources().getColor(R.color.app_blue_color));
            Log.e("TAG---》URL", item.gameInfo.getGame_down_url_mote());
            if (item.gameInfo.getGame_down_url_mote() != null || item.gameInfo.getGame_down_url_mote().indexOf("apk") == -1) {
                index = DownloadManager.getInstance().getDownloadTaskStatus(item.gameInfo.getGame_down_url_mote());
                switch (index) {
                    case CommonDownloadTask.STATUS_NOT:  //未下载  download
                    case CommonDownloadTask.STATUS_NORMAL:
                        btn_state = mContext.getResources().getString(R.string.download_status_start_str);
                        holder.progressBar.setVisibility(View.GONE);
                        holder.linearLayout2.setVisibility(View.GONE);
                        holder.lodingInfo.setVisibility(View.GONE);
                        holder.describe.setVisibility(View.VISIBLE);
                        holder.ll_game.setVisibility(View.VISIBLE);
                        break;
                    case CommonDownloadTask.STATUS_START:  //downloading
                    case CommonDownloadTask.STATUS_PROGRESS:   //
                        btn_state = mContext.getResources().getString(R.string.download_stop_str);
                        holder.progressBar.setVisibility(View.VISIBLE);
                        holder.linearLayout2.setVisibility(View.VISIBLE);
                        holder.lodingInfo.setVisibility(View.VISIBLE);
                        holder.describe.setVisibility(View.GONE);
                        holder.ll_game.setVisibility(View.GONE);

                        holder.appSize.setText(UtilsMy.FormatFileSize(pro*apps/100)+"/"+gameSize);
                        holder.lodingInfo.setText(speed==null?"0Kb/s":speed+"/s");

                        break;
                    case CommonDownloadTask.STATUS_FINISH:  //play
                        btn_state = mContext.getResources().getString(R.string.download_status_open_str);
                        holder.progressBar.setVisibility(View.GONE);
                        holder.linearLayout2.setVisibility(View.GONE);
                        holder.describe.setVisibility(View.VISIBLE);
                        holder.ll_game.setVisibility(View.VISIBLE);
                        break;
                    case CommonDownloadTask.STATUS_STOP:   //stop
                        btn_state = mContext.getResources().getString(R.string.download_status_goon_str);
                        holder.progressBar.setVisibility(View.VISIBLE);
                        holder.linearLayout2.setVisibility(View.VISIBLE);
                        holder.describe.setVisibility(View.GONE);
                        holder.ll_game.setVisibility(View.GONE);
                        holder.lodingInfo.setText(mContext.getResources().getString(R.string.download_stop_str));
                        break;
                    case CommonDownloadTask.STATUS_ERROR:    //download f
                        btn_state = mContext.getResources().getString(R.string.download_fail_str);
                        holder.mgListviewItemInstall.setBackgroundResource(R.drawable.recom_orange_butn);
                        holder.tv_down_name.setTextColor(mContext.getResources().getColor(R.color.app_main_color));
                        holder.progressBar.setVisibility(View.VISIBLE);
                        holder.linearLayout2.setVisibility(View.VISIBLE);
                        holder.describe.setVisibility(View.GONE);
                        holder.ll_game.setVisibility(View.GONE);
                        break;
                    case CommonDownloadTask.STATUS_ZIP_PROGRESS:   // unzip
                    case CommonDownloadTask.STATUS_STSRT_ZIP:
                        btn_state = mContext.getResources().getString(R.string.zip_str);
                        holder.progressBar.setVisibility(View.GONE);
                        holder.linearLayout2.setVisibility(View.GONE);
                        holder.describe.setVisibility(View.VISIBLE);
                        holder.ll_game.setVisibility(View.VISIBLE);
                        break;
                    case CommonDownloadTask.STATUS_ZIP_FAIL:  //unzip failed
                        btn_state = mContext.getResources().getString(R.string.zip_fail_str);
                        holder.mgListviewItemInstall.setBackgroundResource(R.drawable.recom_orange_butn);
                        holder.tv_down_name.setTextColor(mContext.getResources().getColor(R.color.app_main_color));
                        break;
                }
            } else {
                btn_state = "Download";
            }
            holder.tv_down_name.setText(btn_state);

            if (holder.progressBar.getVisibility() == View.VISIBLE)
                holder.progressBar.setProgress(pro);

            final int finalIndex = index;

//            ForumUtil.addTipsInView(tipBeans, holder.tipsLayout, mContext);
//
//            UtilsMy.addTipsInView(gameInfo.getDown_count(), gameSize,gameInfo.getSp_tag_info(), holder.tipsLayout, mContext);

            //游戏下载
//            updateDownloadItemUiType(holder, 0x00);
//            final DownloadTask downloadTask = gameInfo.getDownloadTask();
//            if (downloadTask != null) {
//                setDownloadStatus(holder, downloadTask);
//            } else {
//                setDownNormalStatus(holder.mgListviewItemInstall, gameInfo.getDown_status());
//
//                holder.mgListviewItemInstall.setOnClickListener(new View.OnClickListener() {
//                    @Override
//                    public void onClick(View v) {
//                        if (gameInfo.getPlugin_num().equals(ConstantIntEnum.H5.value() + "")) {
//                            IntentDateBean intentDateBean = new IntentDateBean();
//                            intentDateBean.setLink_type(4);
//                            intentDateBean.setLink_type_val(gameInfo.getGame_down_url_remote());
//                            UtilsMy.sendStatausH5(downloadTask,mContext);
//                            IntentUtil.getInstance().intentActivity(mContext,intentDateBean);
//                            return;
//                        }
//                        Context context = v.getContext();
//                        StatFactory.getInstance(context).sendForumClickDownloadBtn(postId, gameId, AccountUtil_.getInstance_(context).getUid());
//
//                        if (mForumPostsOnClickListener != null)
//                            mForumPostsOnClickListener.onDownloadGameById(gameId);
//                    }
//                });
//            }


            //布局点击事件
//            setOnGoGameDetail(holder.relateLayoutApp, gameInfo);
//            if ((ConstantIntEnum.H5.value() + "").equals(gameInfo.getPlugin_num())) {
//                holder.tipsLayout.setVisibility(View.GONE);
//                holder.mgListviewItemInstall
//                        .setBackgroundResource(R.drawable.recom_blue_butn);
//                holder.mgListviewItemInstall.setText("开始");
//                holder.mgListviewItemInstall.setTextColor(mContext.getResources().getColor(R.color.app_blue_color));
//            } else {
//                holder.tipsLayout.setVisibility(View.VISIBLE);
//                ForumUtil.addTipsInView(tipBeans, holder.tipsLayout, mContext);
//                UtilsMy.addTipsInView(gameInfo.getDown_count(), gameSize, gameInfo.getSp_tag_info(), holder.tipsLayout, mContext);
//                UtilsMy.setCoin(gameInfo.getSp_tag_info(),convertView,gameInfo.getDownloadTask());
//            }
//            holder.relateLayoutApp.setOnClickListener(new View.OnClickListener() {
//                @Override
//                public void onClick(View v) {
//                    Context context = v.getContext();
//                    StatFactory.getInstance(context).sendForumClickRefGame(postId, gameId, AccountUtil_.getInstance_(context).getUid());
//
//                    ForumUtil.goMGMiniDetialActivity(v.getContext(), gameInfo);
//
//                }
//            });
        } catch (Exception e) {
            e.printStackTrace();
        }
        final int finalIndex = index;
        holder.mgListviewItemInstall.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
//                 holder.progressBar.setVisibility(View.VISIBLE);
//                 holder.linearLayout2.setVisibility(View.VISIBLE);
//                 holder.describe.setVisibility(View.GONE);
//                 holder.ll_game.setVisibility(View.GONE);
                if (finalIndex == 0 || finalIndex == -2 || finalIndex == 4 || finalIndex == 1||CommonDownloadTask.STATUS_STOP==finalIndex
                        ||CommonDownloadTask.STATUS_PROGRESS==finalIndex||CommonDownloadTask.STATUS_START==finalIndex) {
                    mAdapterInterface.onAdapterItemClick(v, position);
                } else if (finalIndex == 2) {
                    Toast.makeText(mContext, "Downlaoding...", Toast.LENGTH_SHORT).show();
                }

            }
        });


        return convertView;
    }

    private View getPostImageView(int position, View convertView, ViewGroup parent) {

        PostImageViewHolder holder;
        if (convertView != null) {
            holder = (PostImageViewHolder) convertView.getTag();
        } else {
            holder = new PostImageViewHolder();
            convertView = LayoutInflater.from(mContext).inflate(R.layout.mg_forum_post_activity_item_post_image, null);
            holder.imgV = (SimpleDraweeView) convertView.findViewById(R.id.img);
            holder.imgTagGifV = (TextView) convertView.findViewById(R.id.img_tag_gif);

            convertView.setTag(holder);
        }

        try {
            ViewBean.PostImage item = (ViewBean.PostImage) getItem(position);
            if (item == null) return convertView;

            preCalcImageSize(mContext, item.imgUrlLarge.get(item.imgIndex));
            ImageParam p = getParam(item.imgUrl);

            if (p != null) {
                RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(p.width, p.height);
                holder.imgV.setLayoutParams(params);
//                MyImageLoader.load(holder.imgV, item.imgUrl);
                holder.imgV.setImageURI(item.imgUrl);
            } else {
//                displayImage(item.imgUrl, getNewPostImageImageLoadingTarget(item.imgUrl, holder.imgV));

                loadPostImage(holder.imgV, item.imgUrl);
            }

            //view raw image  查看大图
//            ForumUtil.setShowLargeImagePreviwer(holder.imgV, item.imgIndex, item.imgUrlLarge);


        } catch (Exception e) {
            e.printStackTrace();
        }
        return convertView;
    }


    public void loadPostImage(final SimpleDraweeView view, String src) {
        try {
            view.getHierarchy().setPlaceholderImage(R.drawable.main_normal_icon);
            ControllerListener controllerListener = new ControllerListener<ImageInfo>() {
                @Override
                public void onSubmit(String id, Object callerContext) {
                    view.setMinimumHeight(getPostImageDefaultHeight(view.getContext()));
                }

                @Override
                public void onFinalImageSet(String id, ImageInfo imageInfo, Animatable animatable) {
                    try {
                        setPostImageParam(id, view, imageInfo);

                        if (imageInfo != null) {
                            ImageParam p = new ImageParam();
                            p.width = imageInfo.getWidth();
                            p.height = imageInfo.getHeight();
                            addParam(id, p);
                        }

                    } catch (Exception ex) {
                        ex.printStackTrace();
                    }
                }

                @Override
                public void onIntermediateImageSet(String id, ImageInfo imageInfo) {

                }

                @Override
                public void onIntermediateImageFailed(String id, Throwable throwable) {

                }

                @Override
                public void onFailure(String id, Throwable throwable) {

                }

                @Override
                public void onRelease(String id) {

                }
            };

            DraweeController draweeController = Fresco.newDraweeControllerBuilder().setControllerListener(controllerListener)
                    .setUri(src)
                    .build();
            view.setController(draweeController);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private ViewGroup.LayoutParams setPostImageParam(String s, final View view, ImageInfo imageInfo) {
        int rawHeight = ViewGroup.LayoutParams.MATCH_PARENT;
        int rawWidth = ViewGroup.LayoutParams.WRAP_CONTENT;

        if (imageInfo != null) {
            rawWidth = imageInfo.getWidth();
            rawHeight = imageInfo.getHeight();
        } else {
            return null;
        }

        //set radio width and height
        Context context = view.getContext();
        Resources res = context.getResources();
        int widthPixels = res.getDisplayMetrics().widthPixels;

        //mg_forum_post_item_padding is left and right padding dimen
        float radioDefault = 1.5f;
        int paddingLR = res.getDimensionPixelSize(R.dimen.mg_forum_item_padding);
        int itemWidth = widthPixels - paddingLR * 2;
        int itemHeight = (int) (1.0f * itemWidth / radioDefault);

        //calc itemHeight
        float ratio = 1.0f * rawHeight / rawWidth;
        itemHeight = (int) (1.0f * itemWidth * ratio);

        //generate params
        ViewGroup.LayoutParams params = view.getLayoutParams();
        params.width = itemWidth;
        params.height = itemHeight;

        //set to view
        Logger.getLogger(TAG + "setPostImageParam-->" + "rawHeight=" + rawHeight + " rawWidth=" + rawWidth + " ratio=" + ratio + " itemHeight=" + itemHeight + " itemWidth=" + itemWidth + "\n" + s);
        if (view != null) {
            view.setMinimumHeight(0);
            view.setLayoutParams(params);
        }

        return params;
    }

    int postImageDefaultHeight = 0;

    private int getPostImageDefaultHeight(Context context) {
        if (context == null) return 0;
        if (postImageDefaultHeight == 0) {
            Resources res = context.getResources();
            int widthPixels = res.getDisplayMetrics().widthPixels;

            //mg_forum_post_item_padding is left and right padding dimen
            float radioDefault = 1.5f;
            int paddingLR = res.getDimensionPixelSize(R.dimen.mg_forum_item_padding);
            int itemWidth = widthPixels - paddingLR * 2;
            int itemHeight = (int) (1.0f * itemWidth / radioDefault);

            postImageDefaultHeight = itemHeight;
        }
        return postImageDefaultHeight;
    }

    void preCalcImageSize(Context context, String imgUrl) {
        Integer[] size = ForumUtil.getImageSize(imgUrl);

        if (null != size) {
            ImageParam p = new ImageParam();

            int rawWidth = size[0];
            int rawHeight = size[1];

            //set radio width and height
            Resources res = context.getResources();
            int widthPixels = res.getDisplayMetrics().widthPixels;

            //mg_forum_post_item_padding is left and right padding dimen
            float radioDefault = 1.5f;
            int paddingLR = res.getDimensionPixelSize(R.dimen.mg_forum_item_padding);
            int itemWidth = widthPixels - paddingLR * 2;
            int itemHeight = (int) (1.0f * itemWidth / radioDefault);

            //calc itemHeight
            float ratio = 1.0f * rawHeight / rawWidth;
            itemHeight = (int) (1.0f * itemWidth * ratio);

            p.width = itemWidth;
            p.height = itemHeight;
            addParam(imgUrl, p);
        }
    }


    private View getPostVideoView(int position, View convertView, ViewGroup parent) {

        PostVideoViewHolder holder;
        if (convertView != null) {
            holder = (PostVideoViewHolder) convertView.getTag();
        } else {
            holder = new PostVideoViewHolder();
            convertView = LayoutInflater.from(mContext).inflate(R.layout.mg_forum_post_activity_item_post_video1, null);
            holder.coverV = (SimpleDraweeView) convertView.findViewById(R.id.cover);
            holder.playV = (ImageView) convertView.findViewById(R.id.play);
            holder.iv_play = (ImageView) convertView.findViewById(R.id.iv_play);
//            holder.videoPlayer = (StandardVideoView) convertView.findViewById(R.id.videoPlayer);

            convertView.setTag(holder);
        }


        try {
            ViewBean.PostVideo item = (ViewBean.PostVideo) getItem(position);
            if (item == null) return convertView;

            /*holder.imgV.setScaleType(ImageView.ScaleType.FIT_XY);
            MyImageLoader.load(holder.imgV, item.imgUrl);
//            ForumUtil.setViewAction(holder.imgV, item.videoUrl, "-1");
            setPostImageAndVideoImageParam(holder.imgV, item.imgUrl);
            setOnGoPostVideoPlayer(holder.imgV, item.videoUrl, item.actionBarTitle);*/

            int itemHeight = getPostVideoDefaultHeight(mContext);

            final String url = item.videoUrl;
            final String thumbnail = item.imgUrl;
            if (holder.coverV != null) {
                RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, itemHeight);
                holder.coverV.setLayoutParams(params);
                holder.coverV.setScaleType(ImageView.ScaleType.FIT_XY);
                holder.coverV.setImageURI(thumbnail);
                setOnGoPostVideoPlayer(holder.coverV, url, position + "");
            }


            holder.iv_play.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    mContext.startActivity(SetWebViewActivity.buildIntent(mContext, url));

                }
            });


//            if (holder.videoPlayer != null) {
//                holder.videoPlayer.setMuteWhenPlay(false);
//                RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, itemHeight);
//                holder.videoPlayer.setLayoutParams(params);
////                MyImageLoader.load(holder.videoPlayer.thumbImageView, R.drawable.video_bg, thumbnail);
//                holder.videoPlayer.thumbImageView.setImageURI(thumbnail);
//                holder.videoPlayer.setUp(
//                        url,
//                        JCVideoPlayer.SCREEN_LAYOUT_LIST,
//                        "",
//                        thumbnail);
//            }

        } catch (Exception e) {
            Toast.makeText(mContext, "null", Toast.LENGTH_SHORT).show();
            e.printStackTrace();
        }
        return convertView;
    }

    public void setOnGoPostVideoPlayer(View v, final String videoSrc, final String position) {
        if (v == null) return;
        v.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                int playPosition = Integer.parseInt(position);
//                ForumUtil.goVideoPlayer(v.getContext(), videoSrc, position);

                if (mForumPostsOnClickListener != null) {
                    mForumPostsOnClickListener.onPlayVideo(playPosition);
                }

            }
        });
    }

    int postVideoDefaultHeight = 0;

    private int getPostVideoDefaultHeight(Context context) {
        if (context == null) return 0;
        if (postVideoDefaultHeight == 0) {
            Resources res = context.getResources();
            int widthPixels = res.getDisplayMetrics().widthPixels;

            //mg_forum_post_item_padding is left and right padding dimen
            float radioDefault = 1.8f;
            int paddingLR = res.getDimensionPixelSize(R.dimen.mg_forum_item_padding);
            int itemWidth = widthPixels - paddingLR * 2;
            int itemHeight = (int) (1.0f * itemWidth / radioDefault);

            postVideoDefaultHeight = itemHeight;
        }
        return postVideoDefaultHeight;
    }

    private View getPostImageThumbnailView(int position, View convertView, ViewGroup parent) {
        PostImageThumbnailViewHolder holder;
        if (convertView != null) {
            holder = (PostImageThumbnailViewHolder) convertView.getTag();
        } else {
            holder = new PostImageThumbnailViewHolder();
            convertView = LayoutInflater.from(mContext).inflate(R.layout.mg_forum_post_activity_item_post_image_thumbnail, null);
            holder.imgContainerV = (RelativeLayout) convertView.findViewById(R.id.forum_post_media_container);
            holder.imgCountV = (TextView) convertView.findViewById(R.id.images_count);

            convertView.setTag(holder);
        }

        try {
            ViewBean.PostImageThumbnail item = (ViewBean.PostImageThumbnail) getItem(position);
            if (item == null) return convertView;

            processImageThumbnailContent(holder.imgContainerV, item.imgUrlList, item.imgUrlLargeList);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return convertView;
    }

    //region 缩略图显示
    LinearLayout.LayoutParams imageThumbnailParams;

    private void processImageThumbnailContent(RelativeLayout container, final List<String> image_list, final List<String> raw_pic_list) {
        if (image_list == null || image_list.size() == 0) {
            container.setVisibility(View.GONE);
            return;
        }
        if (imageThumbnailParams == null)
            imageThumbnailParams = getThumbnailItemParam();//for welcome,forum,profile image show param

//        container.setVisibility(View.VISIBLE);

        TextView count = (TextView) container.findViewById(R.id.images_count);
        if (image_list != null && image_list.size() > 3) {
            count.setVisibility(View.VISIBLE);
            count.setText(mContext.getResources().getString(R.string.forum_post_img_count, image_list.size()));
//            count.setText("共" + image_list.size() + "张");
        } else {
            count.setVisibility(View.GONE);
        }

        //set view attr and layout params
        DisplayMetrics dm = mContext.getResources().getDisplayMetrics();
        float density = dm.density;
        int spacing = (int) (6 * density);

        int[] imgIds = new int[]{R.id.img_m_1, R.id.img_m_2, R.id.img_m_3};
        for (int i = 0; i < 3; i++) {
            SimpleDraweeView img = (SimpleDraweeView) container.findViewById(imgIds[i]);
            LinearLayout.LayoutParams cParams = new LinearLayout.LayoutParams(imageThumbnailParams.width, imageThumbnailParams.height);
            if (i < image_list.size()) {
                String url = image_list.get(i);
                img.setVisibility(View.VISIBLE);
                if (i > 0)
                    cParams.setMargins(spacing, 0, 0, 0);
                else
                    cParams.setMargins(0, 0, 0, 0);
                img.setLayoutParams(cParams);
                img.setScaleType(ImageView.ScaleType.CENTER_CROP);
                //            MyImageLoader.load(img, url);
                img.setImageURI(url);
                final int imgIndex = i;
                img.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        String[] strArr = new String[raw_pic_list.size()];
                        raw_pic_list.toArray(strArr);
//                        ForumUtil.goImagePagerActivity(v.getContext(), imgIndex, strArr);
                    }
                });

                continue;
            } else {
                img.setVisibility(View.GONE);
            }
        }
    }

    private View getPostMessageView(int position, View convertView, ViewGroup parent) {
        PostMessageViewHolder holder;
        if (convertView != null) {
            holder = (PostMessageViewHolder) convertView.getTag();
        } else {
            holder = new PostMessageViewHolder();
            convertView = LayoutInflater.from(mContext).inflate(R.layout.mg_forum_post_activity_item_post_message, null);
            holder.messageV = (TextView) convertView.findViewById(R.id.forum_post_message);

            convertView.setTag(holder);
        }

        try {
            ViewBean.PostMessage item = (ViewBean.PostMessage) getItem(position);
            if (item == null) return convertView;

            holder.messageV.setLineSpacing(0.f, 1.3f);
//            holder.messageV.setTextIsSelectable(true);
            holder.messageV.setMovementMethod(LinkMovementMethod.getInstance());
//            holder.messageV.setMaxLines(Integer.MAX_VALUE);
            setCustomTextView(holder.messageV, item.message, item.startWithBest, item.isAsk, item.askMoney, item.tagInfos);

            setOnCommentReplyCancel(convertView);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return convertView;
    }

    //region TAG
    private void setCustomTextView(TextView tv, SpannableStringBuilder message, boolean best, boolean ask, String moneyForAnswer, List<ForumBean.ForumPostsBean.TagInfo> tagInfos) {
        SpannableStringBuilder ssb = new SpannableStringBuilder();

//        ForumUtil.attachPostBeanTag(tv.getContext(), ssb, tagInfos);
//        ForumUtil.attachPostBeanFlag(tv, ssb, best, ask, moneyForAnswer);

        ssb.append(message);

        tv.setText(ssb);
    }

    private View getPostSubjectView(int position, View convertView, ViewGroup parent) {
        PostSubjectViewHolder holder;
        if (convertView != null) {
            holder = (PostSubjectViewHolder) convertView.getTag();
        } else {
            holder = new PostSubjectViewHolder();
            convertView = LayoutInflater.from(mContext).inflate(R.layout.mg_forum_post_activity_item_post_subject, null);
            holder.bestV = (Button) convertView.findViewById(R.id.forum_post_best);
            holder.subjectV = (TextView) convertView.findViewById(R.id.forum_post_subject);

            convertView.setTag(holder);
        }

        try {
            ViewBean.PostSubject item = (ViewBean.PostSubject) getItem(position);
            if (item == null) return convertView;

//            setTextViewWithBestPre(holder.subjectV, item.isBest, item.subject);
            holder.subjectV.setTextSize(19.f);
            holder.subjectV.setMovementMethod(LinkMovementMethod.getInstance());
            setCustomTextView(holder.subjectV, item.subject, item.isBest, item.isAsk, item.askMoney, item.tagInfos, item.tag_list, item.fid, item.fname);

            setOnCommentReplyCancel(convertView);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return convertView;
    }

    private void setCustomTextView(TextView tv,
                                   String message,
                                   boolean best,
                                   boolean ask,
                                   String moneyForAnswer,
                                   List<ForumBean.ForumPostsBean.TagInfo> tagInfos,
                                   List<RecommendLabelTag> tags,
                                   int fid,
                                   String fname) {
        SpannableStringBuilder ssb = new SpannableStringBuilder();

//        ForumUtil.attachPostBeanTag(tv.getContext(), ssb, tagInfos);
//        ForumUtil.attachPostBeanFlag(tv, ssb, best, ask, moneyForAnswer);
//
//        ForumUtil.attachPostRecommTag(tv.getContext(), ssb, tags, fid, fname);
        ssb.append(TextUtils.isEmpty(message) ? "" : message);

        tv.setText(ssb);
    }

    private View getCommentHeaderView(int position, View convertView, ViewGroup parent) {
        //pl
        CommentHeaderViewHolder holder;
        if (convertView != null) {
            holder = (CommentHeaderViewHolder) convertView.getTag();
        } else {
            holder = new CommentHeaderViewHolder();
            convertView = LayoutInflater.from(mContext).inflate(R.layout.mg_forum_post_activity_item_comment_header, null);
            holder.avatarV = (SimpleDraweeView) convertView.findViewById(R.id.comment_avatar_src);
            holder.nicknameV = (TextView) convertView.findViewById(R.id.comment_nickname);
            holder.addTimeV = (TextView) convertView.findViewById(R.id.comment_add_time);
            holder.replyV = (ImageView) convertView.findViewById(R.id.comment_reply);
            holder.floorV = (TextView) convertView.findViewById(R.id.comment_floor);
            holder.postHostV = (Button) convertView.findViewById(R.id.forum_post_host);
            holder.moderatorV = (ImageView) convertView.findViewById(R.id.forum_post_moderator);
            holder.isOfficial = (ImageView) convertView.findViewById(R.id.isOfficial);
            holder.flagBestAnswerV = (ImageView) convertView.findViewById(R.id.flagBestAnswer);
//            holder.vipFlagV = (VipView) convertView.findViewById(R.id.vipFlag);

            holder.moderator = (TextView) convertView.findViewById(R.id.moderator);
            holder.member_honor = (TextView) convertView.findViewById(R.id.member_honor);
//            holder.groupName = (TextView) convertView.findViewById(R.id.groupName);
//            holder.groupParent = convertView.findViewById(R.id.groupParent);

            holder.divider = convertView.findViewById(R.id.divider);

            convertView.setTag(holder);
        }

        try {
            ViewBean.CommentHeader item = (ViewBean.CommentHeader) getItem(position);
            if (item == null) return convertView;

            if (item.showDivider) {
                holder.divider.setVisibility(View.VISIBLE);
            } else {
                holder.divider.setVisibility(View.GONE);
            }

            try {
//                UtilsMy.setVipTextColor(mContext, holder.nicknameV, item.vip_level, item.svip_level);
//                holder.vipFlagV.setVipData(item.vip_level, item.svip_level);
            } catch (Exception e) {
                e.printStackTrace();
            }

            switch (item.solveFlag) {
                case 1:
                    holder.flagBestAnswerV.setVisibility(View.VISIBLE);
                    break;
                default:
                    holder.flagBestAnswerV.setVisibility(View.GONE);
                    break;
            }

            holder.nicknameV.setText(item.nickName);
            holder.addTimeV.setText(DateUtils.FormatForDownloadTime(item.timestamps * 1000));

//            MyImageLoader.loadUserIcon(holder.avatarV, item.avatarSrc);

            if (item.isPostHost) {
                holder.postHostV.setVisibility(View.VISIBLE);
            } else {
                holder.postHostV.setVisibility(View.GONE);
            }
            if (item.officialAccount) {
//                holder.nicknameV.setTextColor(mContext.getResources().getColor(R.color.app_blue_color));
                holder.isOfficial.setVisibility(View.VISIBLE);
            } else {
                holder.isOfficial.setVisibility(View.GONE);
            }
            if (item.isModerator) {
                holder.nicknameV.setTextColor(mContext.getResources().getColor(R.color.app_blue_color));
                holder.moderatorV.setVisibility(View.VISIBLE);
            } else {
//                holder.nicknameV.setTextColor(mContext.getResources().getColor(R.color.forum_nickname_color));
//                UtilsMy.setVipTextColor(mContext, holder.nicknameV, item.vip_level, item.svip_level, R.color.forum_nickname_color);
                holder.moderatorV.setVisibility(View.GONE);
            }

            if (item.moderator) {
                holder.moderator.setVisibility(View.VISIBLE);
            } else {
                holder.moderator.setVisibility(View.GONE);
            }
            if (!TextUtils.isEmpty(item.member_honor)) {
                holder.member_honor.setVisibility(View.VISIBLE);
                holder.member_honor.setText(item.member_honor);
            } else {
                holder.member_honor.setVisibility(View.GONE);
            }
//            holder.groupName.setText(item.fname);
//            setOnGoForumGroup(holder.groupParent,item.fid);

            String floorStr = "";
            if (item.floor == 1) {
                floorStr = mContext.getResources().getString(R.string.comment_item_floor_1st);
            } else if (item.floor == 2) {
                floorStr = mContext.getResources().getString(R.string.comment_item_floor_2nd);
            } else {
                floorStr = mContext.getResources().getString(R.string.comment_item_floor, item.floor);
            }
            holder.floorV.setText(floorStr);

            setOnCommentReplyCancel(convertView);
//            setOnCommentReply(holder.replyV, item);


//            ForumUtil.goSpec(holder.avatarV, holder.nicknameV, holder.addTimeV);
//            ForumUtil.goSpec1(holder.vipFlagV);


//            setPostGag(holder.avatarV, item.uid);

        } catch (Exception e) {
            e.printStackTrace();
        }
        return convertView;
    }

    class CommentHeaderViewHolder extends ViewHolder {

        public SimpleDraweeView avatarV;
        public TextView nicknameV;
        public TextView addTimeV;
        public ImageView replyV;
        public TextView floorV;
        public Button postHostV;
        public ImageView moderatorV;
        public ImageView isOfficial;
        public ImageView flagBestAnswerV;

        public TextView moderator;
        public TextView member_honor;
        public View divider;
//        public TextView       groupName;
//        public View           groupParent;
    }

    private View getCommentMessageView(int position, View convertView, ViewGroup parent) {
        CommentMessageViewHolder holder;
        if (convertView != null) {
            holder = (CommentMessageViewHolder) convertView.getTag();
        } else {
            holder = new CommentMessageViewHolder();
            convertView = LayoutInflater.from(mContext).inflate(R.layout.mg_forum_post_activity_item_comment_message, null);
            holder.commentMessageV = (TextView) convertView.findViewById(R.id.comment_message);

            convertView.setTag(holder);
        }

        try {
            ViewBean.CommentMessage item = (ViewBean.CommentMessage) getItem(position);
            if (item == null) return convertView;

            holder.commentMessageV.setText(item.message);

//            String cNickname = item.nickname;
//            int cid = item.commentId;
//            int uid = item.uid;
//            setOnCommentReply(convertView, cid, cNickname);
            setOnCommentReplyCancel(convertView);
//            setOnCommentLongClick(holder.commentMessageV, item);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return convertView;
    }

    public interface ForumPostsOnClickListener {
        //帖子相关
        void onPraise(int pid);

        void onDelete(int pid);

        void onReport();

        void onPlayVideo(int position);

        //回复相关
        void onReplyLongClick(View v, int rid);

        void onReplyCancel();

        void onReplyDelete(int rid);

        void onReplyReport(int rid);

        void onReplyReply(int cid, int rid, String rNickname);

        //评论相关
        void onCommentLongClick(View v, int cid);

        void onCommentDelete(int cid);

        void onCommentReply(int cid, String cNickname);

        void onCommentReport(int cid);

        void onCommentHelpSolve(int cid);

        void onDownloadGameById(String gameId);

        void onPostGag(int gagUid);
    }

    private ForumPostsOnClickListener mForumPostsOnClickListener = null;

    public void setOnCommentReplyCancel(View v) {
        v.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (mForumPostsOnClickListener != null) {
                    mForumPostsOnClickListener.onReplyCancel();
                }
            }
        });
    }


    private View getCommentImageView(int position, View convertView, ViewGroup parent) {
        CommentImageViewHolder holder;
        if (convertView != null) {
            holder = (CommentImageViewHolder) convertView.getTag();
        } else {
            holder = new CommentImageViewHolder();
            convertView = LayoutInflater.from(mContext).inflate(R.layout.mg_forum_post_activity_item_comment_image, null);
            holder.imgV = (SimpleDraweeView) convertView.findViewById(R.id.comment_img);

            convertView.setTag(holder);
        }

        try {
            ViewBean.CommentImage item = (ViewBean.CommentImage) getItem(position);
            if (item == null) return convertView;

            if (holder.imgV != null) {
                SimpleDraweeView imageView = holder.imgV;

                preCalcImageSize1(mContext, item.imgUrlLarge.get(item.imgIndex));
                ImageParam p = getParam(item.imgUrl);

                if (p != null) {
                    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(p.width, p.height);
                    int marginTB = 4;
                    int margin = (int) (marginTB * mContext.getResources().getDisplayMetrics().density);
                    params.setMargins(0, margin, 0, margin);
                    imageView.setLayoutParams(params);
//                    MyImageLoader.load(imageView, item.imgUrl);

                    imageView.setImageURI(item.imgUrl);
                } else {
//                    displayImage(item.imgUrl, getNewCommentImageImageLoadingTarget(item.imgUrl, imageView));
//                    loadCommentImage(imageView, item.imgUrl);

                    imageView.setImageURI(item.imgUrl);
                }

//                view raw image
//                ForumUtil.setShowLargeImagePreviwer(imageView, item.imgIndex, item.imgUrlLarge);
            }


        } catch (Exception e) {
            e.printStackTrace();
        }
        return convertView;
    }

    //region 图片预计算，防止重新计算
    public class ImageParam {
        public int width;
        public int height;
    }

    Hashtable<String, ImageParam> imageParams;

    void addParam(String key, ImageParam value) {
        if (imageParams == null) {
            imageParams = new Hashtable<String, ImageParam>();
        }
        imageParams.put(key, value);
    }

    ImageParam getParam(String key) {
        if (imageParams == null) {
            return null;
        }

        return imageParams.get(key);
    }

    private void preCalcImageSize1(Context context, String imgUrl) {
        Integer[] size = ForumUtil.getImageSize(imgUrl);

        if (null != size) {
            ImageParam p = new ImageParam();

            int rawWidth = size[0];
            int rawHeight = size[1];

            //set radio width and height
            Resources res = context.getResources();
            int widthPixels = res.getDisplayMetrics().widthPixels;

            //mg_forum_post_item_padding is left and right padding dimen
            float radioDefault = 1.5f;
            int paddingLR = res.getDimensionPixelSize(R.dimen.mg_forum_forums_item_padding);
            int itemWidth = (int) (widthPixels - paddingLR * 2 - 40 * res.getDisplayMetrics().density);
            int itemHeight = (int) (1.0f * itemWidth / radioDefault);

            //calc itemHeight
            float ratio = 1.0f * rawHeight / rawWidth;
            itemHeight = (int) (1.0f * itemWidth * ratio);

            p.width = itemWidth;
            p.height = itemHeight;
            addParam(imgUrl, p);
        }
    }

    private View getCommentMessageReplyView(int position, View convertView, ViewGroup parent) {
        CommentMessageReplyViewHolder holder;

        try {
            if (convertView != null) {
                holder = (CommentMessageReplyViewHolder) convertView.getTag();
            } else {
                holder = new CommentMessageReplyViewHolder();
                convertView = LayoutInflater.from(mContext).inflate(R.layout.mg_forum_post_activity_item_comment_message_reply, null);
                holder.replyContainerV = (LinearLayout) convertView.findViewById(R.id.comment_reply_container);
                holder.replyDividerV = convertView.findViewById(R.id.comment_reply_divider);
                holder.replyContentV = (TextView) convertView.findViewById(R.id.comment_reply_content);
                holder.replyMoreV = (TextView) convertView.findViewById(R.id.comment_reply_more);
                holder.lineV = convertView.findViewById(R.id.line);
                holder.bottomV = convertView.findViewById(R.id.bottom);
                convertView.setTag(holder);
            }
            ViewBean.CommentMessageReply item = (ViewBean.CommentMessageReply) getItem(position);
            if (item == null) return convertView;
            if (item.commentBean == null) return convertView;

            if (item.showDivider) {
                holder.replyDividerV.setVisibility(View.VISIBLE);
            } else {
                holder.replyDividerV.setVisibility(View.GONE);
            }

            if (!item.hideBottom) {
                holder.lineV.setVisibility(View.VISIBLE);
                holder.bottomV.setVisibility(View.VISIBLE);
            } else {
                holder.lineV.setVisibility(View.GONE);
                holder.bottomV.setVisibility(View.GONE);
            }

            List<ForumBean.ForumCommentReplyBean> replyList = item.commentBean.getReply_list();
            if (replyList != null && replyList.size() != 0) {
//                processCommentReply(holder.replyContainerV, item, true, position);
            } else {
                holder.replyContainerV.removeAllViews();
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
        return convertView;
    }

    class ViewHolder {

    }

    class CommentMessageReplyViewHolder extends ViewHolder {

        public LinearLayout replyContainerV;
        public View replyDividerV;
        public TextView replyContentV;
        public TextView replyMoreV;
        public View lineV;
        public View bottomV;
    }


    private void initAttrs() {
        if (imageThumbnailParams == null)
            imageThumbnailParams = getThumbnailItemParam();//for welcome,forum,profile image show param

    }

    LinearLayout.LayoutParams getThumbnailItemParam() {
        //set view attr and layout params
        DisplayMetrics dm = mContext.getResources().getDisplayMetrics();
        float density = dm.density;
        int widthPixels = dm.widthPixels;
        int thresholdUpper = (int) (210 * density);//unit dp
        int thresholdLower = (int) (160 * density);//unit dp
        int spacing = (int) (6 * density);
        //calculate
        int padding = mContext.getResources().getDimensionPixelSize(R.dimen.mg_forum_forums_item_padding);
        int itemWidth = (int) (widthPixels - padding * 2 - spacing * density * 2) / 3;
        int itemHeight = itemWidth;
        if (itemWidth > thresholdUpper) {
            itemHeight = itemWidth = thresholdUpper;
        } else if (itemWidth > thresholdLower) {
            itemHeight = itemWidth = thresholdLower;
        }
        //apply
        int parentWidth = 0;
        int parentHeight = LinearLayout.LayoutParams.WRAP_CONTENT;

        LinearLayout.LayoutParams cParams = new LinearLayout.LayoutParams(itemWidth, itemHeight);

//      parentWidth = itemWidth * (itemCount + 1) + padding * itemCount;

//      LinearLayout.LayoutParams pParams = new LinearLayout.LayoutParams(parentWidth, parentHeight);
//      container.setLayoutParams(pParams);

        return cParams;
    }

    public enum ViewType {
        POST_HEADER,
        POST_HEADER1,
        POST_SUBJECT,
        POST_MESSAGE,
        POST_IMAGE,
        POST_VIDEO,
        POST_IMAGE_THUMBNAIL,
        POST_GAME,
        POST_FOOTER,
        COMMENT_HEADER,
        COMMENT_MESSAGE,
        COMMENT_IMAGE,
        COMMENT_MESSAGE_REPLY,
        EMPLOYEE_TAGS,
        POST_FOOTER1, BAIDUADBANNER
    }

    public static class ViewBean {
        ViewType viewType;
        Object obj;

        public ViewBean() {
        }

        public ViewBean(ViewType viewType, Object obj) {
            this.viewType = viewType;
            this.obj = obj;
        }

        public ViewType getViewType() {
            return viewType;
        }

        public void setViewType(ViewType viewType) {
            this.viewType = viewType;
        }

        public Object getObj() {
            return obj;
        }

        public void setObj(Object obj) {
            this.obj = obj;
        }

        public static class PostGame {
            public String pid;
            public ForumBean.GameInfo gameInfo;

            public PostGame(String pid, ForumBean.GameInfo gameInfo) {
                this.pid = pid;
                this.gameInfo = gameInfo;
            }
        }

        public static class PostHeader {
            public boolean removeDivider;
            public String avatarSrc;
            public String nickName;
            public long timestamps;
            public boolean isTop;
            public int pid;
            public boolean isModerator;
            public boolean officialAccount;
            public int solveFlag;
            public int vip_level;
            public int svip_level;
            public String battleTitle;
            public String battleColor;

            public PostHeader() {
            }

            public PostHeader(boolean removeDivider,
                              String avatarSrc,
                              String nickName,
                              long timestamps,
                              boolean isTop,
                              int pid,
                              boolean isModerator,
                              boolean officialAccount,
                              int solveFlag,
                              int vip_level,
                              int svip_level,
                              String battleTitle,
                              String battleColor) {
                this.removeDivider = removeDivider;
                this.avatarSrc = avatarSrc;
                this.nickName = nickName;
                this.timestamps = timestamps;
                this.isTop = isTop;
                this.pid = pid;
                this.isModerator = isModerator;
                this.officialAccount = officialAccount;
                this.solveFlag = solveFlag;
                this.vip_level = vip_level;
                this.svip_level = svip_level;
                this.battleTitle = battleTitle;
                this.battleColor = battleColor;
            }
        }

        public static class PostHeader1 {
            public boolean removeDivider;
            public int uid;
            public String avatarSrc;
            public String nickName;
            public long timestamps;
            public boolean isTop;
            public int pid;
            public boolean isModerator;
            public boolean officialAccount;
            public int solveFlag;
            public int vip_level;
            public int svip_level;
            public String battleTitle;
            public String battleColor;
            public boolean moderator;
            public String member_honor;
            public String fname;
            public int fid;

            public PostHeader1() {
            }

            public PostHeader1(boolean removeDivider,
                               int uid,
                               String avatarSrc,
                               String nickName,
                               long timestamps,
                               boolean isTop,
                               int pid,
                               boolean isModerator,
                               boolean officialAccount,
                               int solveFlag,
                               int vip_level,
                               int svip_level,
                               String battleTitle,
                               String battleColor,
                               boolean moderator, String member_honor, String fname, int fid) {
                this.removeDivider = removeDivider;
                this.uid = uid;
                this.avatarSrc = avatarSrc;
                this.nickName = nickName;
                this.timestamps = timestamps;
                this.isTop = isTop;
                this.pid = pid;
                this.isModerator = isModerator;
                this.officialAccount = officialAccount;
                this.solveFlag = solveFlag;
                this.vip_level = vip_level;
                this.svip_level = svip_level;
                this.battleTitle = battleTitle;
                this.battleColor = battleColor;
                this.moderator = moderator;
                this.member_honor = member_honor;
                this.fname = fname;
                this.fid = fid;
            }
        }

        public static class PostSubject {
            public boolean isBest;
            public String subject;
            public boolean isAsk;
            public String askMoney;
            public List<ForumBean.ForumPostsBean.TagInfo> tagInfos;
            public List<RecommendLabelTag> tag_list;
            public int fid;
            public String fname;

            public PostSubject() {
            }

            public PostSubject(boolean isBest, String subject, boolean isAsk, String askMoney, List<ForumBean.ForumPostsBean.TagInfo> tagInfos, List<RecommendLabelTag> tag_list,
                               int fid, String fname) {
                this.isBest = isBest;
                this.subject = subject;
                this.isAsk = isAsk;
                this.askMoney = askMoney;
                this.tagInfos = tagInfos;
                this.tag_list = tag_list;
                this.fid = fid;
                this.fname = fname;
            }
        }

        public static class PostMessage {
            public boolean startWithBest;
            public SpannableStringBuilder message;
            public boolean isAsk;
            public String askMoney;
            public List<ForumBean.ForumPostsBean.TagInfo> tagInfos;

            public PostMessage() {
            }

            public PostMessage(boolean startWithBest, SpannableStringBuilder message, boolean isAsk, String askMoney, List<ForumBean.ForumPostsBean.TagInfo> tagInfos) {
                this.startWithBest = startWithBest;
                this.message = message;
                this.isAsk = isAsk;
                this.askMoney = askMoney;
                this.tagInfos = tagInfos;
            }

            public PostMessage(boolean startWithBest, SpannableStringBuilder message, List<ForumBean.ForumPostsBean.TagInfo> tagInfos) {
                this.startWithBest = startWithBest;
                this.message = message;
                this.tagInfos = tagInfos;
            }
        }

        public static class PostImage {
            public String imgUrl;
            int imgIndex;
            List<String> imgUrlLarge;

            public PostImage() {
            }

            public PostImage(String imgUrl, int imgIndex, List<String> imgUrlLarge) {
                this.imgUrl = imgUrl;
                this.imgIndex = imgIndex;
                this.imgUrlLarge = imgUrlLarge;
            }
        }

        public static class PostVideo {
            public String imgUrl;
            public String videoUrl;
            public String actionBarTitle;

            public PostVideo(String imgUrl, String videoUrl, String actionBarTitle) {
                this.imgUrl = imgUrl;
                this.videoUrl = videoUrl;
                this.actionBarTitle = actionBarTitle;
            }
        }

        public static class PostImageThumbnail {
            public List<String> imgUrlList;
            List<String> imgUrlLargeList;//imgUrlLargeList.size()>=imgUrlList.size()

            public PostImageThumbnail() {
            }

            public PostImageThumbnail(List<String> imgUrlList, List<String> imgUrlLargeList) {
                this.imgUrlList = imgUrlList;
                this.imgUrlLargeList = imgUrlLargeList;
            }
        }

        public static class EmployeeTags {

            public List<RecommendLabelTag> employ_tags;
            public int fid;
            public String fname;

            public EmployeeTags(List<RecommendLabelTag> employ_tags, int fid, String fname) {
                this.employ_tags = employ_tags;
                this.fid = fid;
                this.fname = fname;
            }
        }

        public static class PostFooter {
            public int postId;
            public String fname;
            public int viewTotal;
            public int commentTotal;
            public int praiseTotal;
            public int fid;
            public boolean isPraise;
            public boolean isShowFooterDivider;

            public PostFooter() {
            }

            public PostFooter(int postId, int fid, String fname, int viewTotal, int commentTotal, int praiseTotal, boolean isPraise, boolean isShowFooterDivider) {
                this.postId = postId;
                this.fid = fid;
                this.fname = fname;
                this.viewTotal = viewTotal;
                this.commentTotal = commentTotal;
                this.praiseTotal = praiseTotal;
                this.isPraise = isPraise;
                this.isShowFooterDivider = isShowFooterDivider;
            }
        }

        public static class CommentHeader {
            public boolean showDivider;
            public int uid;
            public int commentId;
            public String avatarSrc;
            public String nickName;
            public long timestamps;
            public boolean isPostHost;
            public int floor;
            public boolean isModerator;
            public boolean officialAccount;
            public int solveFlag;
            public boolean showAdoptBtn;
            public boolean showReport;
            public boolean showDelete;
            public int vip_level;
            public int svip_level;
            public boolean moderator;
            public String member_honor;

            public CommentHeader() {
            }

            public CommentHeader(boolean showDivider,
                                 int uid,
                                 int commentId, String avatarSrc, String nickName, long timestamps, boolean isPostHost, int floor, boolean isModerator, boolean officialAccount, int solveFlag, boolean showAdoptBtn, boolean showReport, boolean showDelete, int vip_level, int svip_level, boolean moderator, String member_honor) {
                this.showDivider = showDivider;
                this.uid = uid;
                this.commentId = commentId;
                this.avatarSrc = avatarSrc;
                this.nickName = nickName;
                this.timestamps = timestamps;
                this.isPostHost = isPostHost;
                this.floor = floor;
                this.isModerator = isModerator;
                this.officialAccount = officialAccount;
                this.solveFlag = solveFlag;
                this.showAdoptBtn = showAdoptBtn;
                this.showReport = showReport;
                this.showDelete = showDelete;
                this.vip_level = vip_level;
                this.svip_level = svip_level;
                this.moderator = moderator;
                this.member_honor = member_honor;
            }
        }

        public static class CommentMessage {

            public int commentId;
            public String message;
            public String nickname;
            public int uid;
            public boolean showReport;
            public boolean showDelete;

            public CommentMessage() {
            }

            public CommentMessage(int commentId, String message, String nickname, int uid, boolean showReport, boolean showDelete) {
                this.commentId = commentId;
                this.message = message;
                this.nickname = nickname;
                this.uid = uid;
                this.showReport = showReport;
                this.showDelete = showDelete;
            }
        }

        public static class CommentImage {
            public String imgUrl;
            public int imgIndex;
            public List<String> imgUrlLarge;

            public CommentImage() {
            }

            public CommentImage(String imgUrl, int imgIndex, List<String> imgUrlLarge) {
                this.imgUrl = imgUrl;
                this.imgIndex = imgIndex;
                this.imgUrlLarge = imgUrlLarge;
            }
        }

        public static class CommentMessageReply {
            public int commentId;
            public ForumBean.ForumCommentBean commentBean;
            public int myAuth;
            public boolean showDivider;
            public boolean isMyPost;
            public int replyItemIndex;
            public boolean lastIndex;
            public boolean hideBottom;

            public CommentMessageReply(int commentId, ForumBean.ForumCommentBean commentBean, int myAuth, boolean showDivider, boolean isMyPost) {
                this.commentId = commentId;
                this.commentBean = commentBean;
                this.myAuth = myAuth;
                this.showDivider = showDivider;
                this.isMyPost = isMyPost;
            }
        }
    }
}
